package fei.yuzhi.com.loveflowers.factory;

import android.support.v4.app.Fragment;

import java.util.HashMap;
import java.util.Map;

import fei.yuzhi.com.loveflowers.fragment.shopping.ShopingFragment;
import fei.yuzhi.com.loveflowers.fragment.classifyFragment.ClassifyFragmnt;
import fei.yuzhi.com.loveflowers.fragment.firstpagefragment.FirstPageFragment;
import fei.yuzhi.com.loveflowers.fragment.mefragment.MeFragment;


/**
 * Created by Administrator on 2016/8/9.
 */
public class FramentFactory {

    private static final int SHOPPING=0,MEIDA=1,TEMAI=2,ME=3;
    private static Map<Integer,Fragment> fragments=new HashMap<>();

    public static Fragment createFragment(int position){

        Fragment fragment=fragments.get(position);
        if (fragment==null){
            switch (position){
                case SHOPPING:
                    fragment=new FirstPageFragment();
                    break;
                case MEIDA:
                    fragment=new ClassifyFragmnt();
                    break;
                case TEMAI:
                    fragment=new ShopingFragment();
                    break;
                case ME:
                    fragment=new MeFragment();
                    break;


            }
            fragments.put(position,fragment);

        }
        return fragment;
    }

}
